package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.NoteDTO;
import com.tianji.learning.domain.po.Note;
import com.tianji.learning.domain.query.NoteQuery;
import com.tianji.learning.domain.vo.NotePageVO;
import com.tianji.learning.service.INoteService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 笔记记录表 前端控制器
 * </p>
 *
 * @author hrz
 * @since 2025-09-04
 */
@RestController
@RequestMapping("/notes")
@RequiredArgsConstructor
public class NoteController {
    private final INoteService noteService;

    @PostMapping
    @ApiOperation("新增笔记")
    public void addNote(@RequestBody NoteDTO noteDTO) {
        noteService.addNote(noteDTO);
    }

    @PostMapping("/gathers/{id}")
    @ApiOperation("采集笔记")
    public void gatherNote(@PathVariable Long id) {
        noteService.gatherNote(id);
    }

    @DeleteMapping("/gathers/{id}")
    @ApiOperation("删除采集的笔记")
    public void deleteNote(@PathVariable Long id) {
        noteService.deleteGatheredNote(id);
    }

    @PutMapping("/{id}")
    @ApiOperation("修改笔记")
    public void updateNote(@PathVariable Long id, @RequestBody NoteDTO noteDTO) {
        noteService.updateNote(id, noteDTO);
    }

    @DeleteMapping("/{id}")
    @ApiOperation("删除笔记")
    public void deleteMyNote(@PathVariable Long id) {
        noteService.deleteMyNote(id);
    }

    @GetMapping("/page")
    @ApiOperation("分页查询笔记")
    public PageDTO<NotePageVO> getNote(@RequestBody NoteQuery noteQuery) {
        return noteService.getNote(noteQuery);
    }


}
